<template>
  <div style="height: 330px;">
     <Modal
      title="电芯信息编码"
      v-model="isShowSelectModal"
      width="400"
    >
      <div>
         <Select class="form-width" :label-in-value="true" v-model="electricValue" ref="selectTextT">
            <Option
              :key="item.code"
              :value="item.code"
              v-for="item in electricTypeList"
            >{{ item.code }}</Option>
        </Select>
      </div>
      <div slot="footer">
        <Button @click="cancel" type="text">取消</Button>
        <Button :loading="isShowLoading" @click="submitFormData" class="newBtn" type="primary">确定</Button>
      </div>
    </Modal>
  </div>
</template>

<script>
import Vue from 'vue';
import { electricTypeConfigApi } from '@/api/electric-type-config';
export default {
  name: 'ElectricTypeSelect',
  data() {
    return {
      electricTypeList: [],
      isShowSelectModal:false,
      isShowLoading: false,
      electricValue:''
    };
  },
  computed: {},
  watch: {},
  filters: {},
  created() {},
  mounted() {
    this.initElectricType();
  },
  beforeCreate() {
  },
  beforeMount() {
  },
  beforeUpdate() {
  },
  updated() {
  },
  beforeDestroy() {
  },
  destroyed() {
  },
  activated() {
  },
  methods: {
     // 打开Modal
    showModal() {
      this.isShowSelectModal = true;
      this.initElectricType();
    },
    submitFormData(){
      this.$emit("childFn", this.electricValue);
      this.$refs.selectTextT.clearSingleSelect()
      this.isShowSelectModal=false;
    },
     cancel() {
      this.$refs.selectTextT.clearSingleSelect()
      this.isShowSelectModal=false;
    },
     //电芯编码
    async initElectricType(){
      let result = await electricTypeConfigApi.getElectricType();
      this.electricTypeList = result.data;
    },
  }
};
</script>
<style lang="less" scoped>
</style>
